using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Acms.WebControls
{
    public class IndexField : DataControlField
    {

        protected override DataControlField CreateField()
        {
            return new IndexField();
        }

        public override void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex)
        {
            if (cell == null)
            {
                return;
            }
            if (cellType == DataControlCellType.DataCell)
            {
                int recordNo = 0;
                if (this.Control is GridView)
                {
                    recordNo = (((GridView)this.Control).PageIndex * ((GridView)this.Control).PageSize) + rowIndex + 1;
                }
                else
                {
                    recordNo = rowIndex + 1;
                }
                cell.Text = recordNo.ToString();
            }
            else
            {
                base.InitializeCell(cell, cellType, rowState, rowIndex);
            }
        }

    }
}
